#ifndef CODEBOOK_H
#define CODEBOOK_H
#define CHANNELS 3

#ifndef CV_H
#define CV_H
#include "cv.h"
using namespace cv;
#endif

#ifndef HIGHGUI_H
#define HIGHGUI_H
#include "highgui.h"
#endif

#ifndef CXCORE_H
#define CXCORE_H
#include "cxcore.h"
#endif

#ifndef IOSTREAM_H
#define IOSTREAM_H
#include <iostream>
using namespace std;
#endif

#ifndef MATH_H
#define MATH_H
#include <math.h>
#endif

typedef struct CodeWord{
	float valueRGB[CHANNELS];
	float maxIntensity;
	float minIntensity;
	unsigned int frequency;
	unsigned int maxNegRunLen;
	unsigned int firstVisity;
	unsigned int lastVisity;
};
class CodeBook{
public:
	CodeWord **m_codeWords;
	unsigned int m_numEntries;
	unsigned int m_time;
public:
	CodeBook();
	~CodeBook();
	float ColorDist(const uchar *pixel, const CodeWord &cw);
	bool Brightness(const CodeWord &cw, float inten, float alph, float beta);
	void UpdateCodeBook(const uchar *pixel, float threshhold, float alph, float beta);
	void ClearStaleEntries();
	void CreateModel(Mat *frames, unsigned int frameCount, float threshhold, float alph, float beta);
	uchar BackgroundDiff(const uchar *pixel, float threshhold, float alph, float beta);
};
#endif